<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>position</title>
<meta name="description" content="CSS3参考手册之:position" />
<meta name="keywords" content="position, css3, css3参考手册" />
<meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" />
<meta name="robots" content="all" />
<!--[if lte IE 8]>
<script src="../../js/html5.js"></script>
<![endif]-->
<link rel="stylesheet" href="../../skin/article.css" />
</head>
<body>
<nav id="guide" class="g-mod">
	<div class="from">
		<a href="http://css.doyoe.com/" target="_blank">CSS3参考手册</a>
		<span>&#187;</span>
		<a href="../index.htm">属性列表</a>
		<span>&#187;</span>
		<a href="index.htm" id="category" rel="properties/positioning" name="position">定位属性</a>
		<span>&#187;</span>
	</div>
	<div class="to">
		<span class="label">相关内容：</span>
		<div class="g-combobox g-transition">
			<a href="?" class="g-transition target">
				<strong>其它定位属性参考</strong>
				<span>选择其它项<!--[if lte IE 7]><ins>IE7 and earlier, Get to die</ins><![endif]--></span>
			</a>
			<div class="g-transition list">
				<ul>
					<!-- 插入分类快速导航 -->
				</ul>
			</div>
		</div>
	</div>
</nav>
<header id="hd">
	<section id="title" class="g-mod">
		<h1 class="tit">position</h1>
		<ul class="info">
			<li><strong>版本：CSS2/3</strong></li>
			<li>2018.2.27</li>
		</ul>
		<!-- 插入浏览器信息 -->
	</section>
</header>
<section id="bd">
	<section id="syntax" class="g-mod g-attr">
		<h2 class="tit">语法：</h2>
		<div class="cont">
			<p><strong>position</strong>：<mark class="defaultvalue">static</mark> | relative | absolute | fixed | <ins class="g-color-css3-new" title="css3">sticky</ins></p>
			<p><strong>默认值</strong>：<mark class="defaultvalue">static</mark></p>
			<p><strong>适用于</strong>：除<a href="../layout/display.htm" class="g-property">display</a>属性定义为<code class="g-value">table-column-group | table-column</code>之外的所有元素</p>
			<p><strong>继承性</strong>：无</p>
			<p><strong>动画性</strong>：否</p>
			<p><strong>计算值</strong>：指定值</p>
			<p><strong>媒　体</strong>：视觉</p>
		</div>
	</section>
	<section id="value" class="g-mod g-attr">
		<h2 class="tit">取值：</h2>
		<div class="cont">
			<dl>
				<dt>static：</dt>
				<dd>对象遵循常规流。此时4个定位偏移属性不会被应用。</dd>
				<dt>relative：</dt>
				<dd>对象遵循常规流，并且参照自身在常规流中的位置通过<a href="top.htm" class="g-property">top</a>，<a href="right.htm" class="g-property">right</a>，<a href="bottom.htm" class="g-property">bottom</a>，<a href="left.htm" class="g-property">left</a>这4个定位偏移属性进行偏移时不会影响常规流中的任何元素。</dd>
				<dt>absolute：</dt>
				<dd>对象脱离常规流，此时偏移属性参照的是离自身最近的定位祖先元素，如果没有定位的祖先元素，则一直回溯到<code class="g-code">body</code>元素。盒子的偏移位置不影响常规流中的任何元素，其<code class="g-property">margin</code>不与其他任何<code class="g-property">margin</code>折叠。</dd>
				<dt>fixed：</dt>
				<dd>与<code class="g-value">absolute</code>一致，但偏移定位是以窗口为参考。当出现滚动条时，对象不会随着滚动。</dd>
				<dt class="g-color-css3-new">sticky：</dt>
				<dd>对象在常态时遵循常规流。它就像是<code class="g-value">relative</code>和<code class="g-value">fixed</code>的合体，当在屏幕中时按常规流排版，当卷动到屏幕外时则表现如<code class="g-value">fixed</code>。该属性的表现是现实中你见到的吸附效果。（CSS3）</dd>
			</dl>
		</div>
		<div class="related">
			<p class="g-color-light">* CSS3新增属性可能存在描述错误及变更，仅供参考，持续更新</p>
		</div>
	</section>
	<section id="intro" class="g-mod g-attr">
		<h2 class="tit">说明：</h2>
		<div class="cont">
			<strong>用于指定一个元素在文档中的定位方式</strong>
			<ul>
				<li>当<code class="g-property">position</code>的值为<code class="g-value">非static</code>时，其层叠级别通过<a href="z-index.htm" class="g-property">z-index</a>属性定义。</li>
				<li>绝对定位的元素，在<a href="top.htm" class="g-property">top</a>，<a href="right.htm" class="g-property">right</a>，<a href="bottom.htm" class="g-property">bottom</a>，<a href="left.htm" class="g-property">left</a>属性未设置时，会紧随在其前面的兄弟元素之后，但在位置上不影响常规流中的任何元素。用这个特性你或许会干这样的事：<a href="http://demo.doyoe.com/css/auto-list/absolute-flow.htm" target="_blank" class="external" rel="external">demo</a></li>
				<li>对应的脚本特性为<strong>position</strong>。</li>
			</ul>
		</div>
	</section>
	<section id="compatible" class="g-mod g-attr">
		<h2 class="tit">兼容性：</h2>
		<div class="cont">
			<ul class="support-type">
				<li><span class="support">浅绿</span> = 支持</li>
				<li><span class="unsupport">红色</span> = 不支持</li>
				<li><span class="partsupport">粉色</span> = 部分支持</li>
			</ul>
			<table class="g-data">
				<thead>
					<tr>
						<th>Values</th>
						<th>IE</th>
						<th>Firefox</th>
						<th>Chrome</th>
						<th>Safari</th>
						<th>Opera</th>
						<th>iOS Safari</th>
						<th>Android Browser</th>
						<th>Android Chrome</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><strong>Basic Support</strong></td>
						<td rowspan="2" class="support">8.0+<sup><a href="#support1">#1</a></sup></td>
						<td rowspan="2" class="support">40.0+</td>
						<td rowspan="2" class="support">40.0+</td>
						<td rowspan="2" class="support">8.0+</td>
						<td rowspan="2" class="support">40.0+</td>
						<td rowspan="2" class="support">8.0+</td>
						<td rowspan="2" class="support">4.4+</td>
						<td rowspan="2" class="support">28.0+</td>
					</tr>
					<tr>
						<td>fixed</td>
					</tr>
					<tr>
						<td rowspan="2"><ins class="g-color-css3-new">sticky</ins></td>
						<td class="unsupport">15.0</td>
						<td rowspan="2" class="partsupport">40.0-58.0 <sup><a href="#support2">#2</a></sup></td>
						<td class="unsupport">55.0</td>
						<td rowspan="2" class="support">8.0-11.0<sup class="fix">-webkit-</sup></td>
						<td class="unsupport">41.0</td>
						<td rowspan="2" class="support">8.0-11.3<sup class="fix">-webkit-</sup></td>
						<td class="unsupport">55.0</td>
						<td class="unsupport">55.0</td>
					</tr>
					<tr>
						<td class="support">16.0+</td>
						<td class="partsupport">56.0-64.0 <sup><a href="#support3">#3</a></sup></td>
						<td class="partsupport">42.0-50.0 <sup><a href="#support3">#3</a></sup></td>
						<td class="partsupport">56.0-62.0 <sup><a href="#support3">#3</a></sup></td>
						<td class="partsupport">56.0-64.0 <sup><a href="#support3">#3</a></sup></td>
					</tr>
				</tbody>
			</table>
			<ol class="support-info">
				<li id="support1">IE如果在 <a href="http://msdn.microsoft.com/en-us/library/ie/ms531140(v=vs.85).aspx" rel="external" class="external" target="_blank">quirks mode</a>下将不支持；</li>
				<li id="support2">Firefox40.0-58.0 不支持将该值应用到任何<code class="g-code">table</code>相关的元素上，<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=975644" rel="external" class="external" target="_blank">详细</a>；</li>
				<li id="support3">Chrome56.0-64.0 不支持将该值应用到<code class="g-code">thead</code>和<code class="g-code">tr</code>元素上，<a href="https://bugs.chromium.org/p/chromium/issues/detail?id=702927" rel="external" class="external" target="_blank">详细</a>；</li>
			</ol>
		</div>
	</section>
	<section id="example" class="g-mod g-attr">
		<h2 class="tit">示例：</h2>
		<div class="cont">
			<textarea cols="90" rows="10">
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>position_CSS参考手册_web前端开发参考手册</title>
<meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" />
<style>
#position {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 150px;
	height: 40px;
	margin: -20px 0 0 -75px;
	padding: 0 10px;
	background: #eee;
	line-height: 2.4;
}
</style>
</head>
<body>
<div id="position">水平垂直居中的对象</div>
</body>
</html>
			</textarea>
			<p><input type="button" value="运行" class="g-btn g-btn-sure" /></p>
		</div>
	</section>
</section>
<footer id="ft">
	<aside id="rights" class="g-mod">
		<!-- 插入浏览器及版权信息 -->
	</aside>
</footer>
<script src="../../js/jquery.js"></script>
<script src="../../js/inner.js"></script>
</body>
</html>